<template>
	<view class="content">
		<image src="../../static/mine/blue-bg.png" mode="widthFix" class="bg-img"></image>
		<CustomNav :topBgColor="topBgColor" :color="titleColor" :backColor="'#999'" :isBack="true" :custom="custom"
			:title="'我的积分'"></CustomNav>
		<view class="title-item">
			<view class="name">当前积分</view>
			<view class="title FangZhengHanZhenGuangBiaoJianTi">{{myScore}}</view>
		</view>
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id">
					<view class="left-item">
						<view class="title" v-if="item.operateType==1">发布随手拍</view>
						<view class="title" v-else-if="item.operateType==2">审核通过</view>
						<view class="title" v-else-if="item.operateType==3">积分核销</view>
						<view class="title" v-else-if="item.operateType==4">积分清零</view>
						<view class="time">{{item.crtTimeText}}</view>
					</view>
					<view v-if="item.operateType==3||item.operateType==4" class="score1">{{item.score}}</view>
					<view v-else class="score">+{{item.score}}</view>
				</view>
			</template>
			<view v-else-if="list.length==0&&!listConf.more" style="text-align: center;">暂无数据</view>
			<view v-if="list.length>0&&!listConf.more" style="text-align: center;margin-top: 20rpx;">没有更多了</view>
		</view>
	</view>
</template>

<script>
	import {
		getCustomNavData,
		isMore
	} from '@/util/util.js'
	import {
		getScoreById
	} from '@/api/ranking.js'
	import {
		getStorage
	} from '@/util/auth';
	export default {
		data() {
			return {
				custom: null,
				topBgColor: 'rgba(0,0,0,0)',
				titleColor: '#fff',
				myScore: 0,
				list: [],
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				}
			}
		},
		methods: {
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getScoreById({
					page: this.listConf.page,
					limit: this.listConf.limit
				}).then(data => {
					uni.hideLoading()
					if (!data) {
						data = {
							myScore: 0,
							count: 0,
							sortList: [],
						}
					}
					if (refresh) {
						this.list = data.sortList;
						this.myScore = data.myScore
					} else {
						this.list = [...this.list, ...data.sortList]
					}
					this.listConf.more = isMore(this.listConf.page, this.listConf.limit, data.count);
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onReachBottom() {
			if (this.listConf.more) {
				this.listConf.page++;
				this.getList()
			}
		},
		onPageScroll(e) {
			if (e.scrollTop >= 50) {
				this.topBgColor = '#117DFF';
			} else {
				this.topBgColor = 'rgba(0,0,0,0)';
			}
		},
		onLoad() {
			this.custom = getCustomNavData();
			this.getList(true)
		}
	}
</script>

<style lang="scss">
	page {
		background: #F5F5F5;
	}

	.content {
		background: #F5F5F5;
		width: 100%;


		.bg-img {
			width: 100%;
			//position: relative;
		}

		.title-item {
			position: absolute;
			margin-top: -380rpx;
			display: flex;
			flex-direction: row;
			margin-left: 80rpx;
			align-items: center;

			.title {
				font-size: 68rpx;
				color: #fff;
			}

			.name {
				color: #fff;
				font-size: 36rpx;
				margin-right: 20rpx;
			}
		}

		.info-block {
			min-height: 60vh;
			display: flex;
			flex-direction: column;
			background: #F5F5F5;
			margin-top: -210rpx;
			border-radius: 60rpx;
			height: auto;
			position: relative;
			padding: 30rpx;

			.info-item {
				background-color: #fff;
				height: 160rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-top: 30rpx;
				align-items: center;
				border-radius: 20rpx;
				padding-left: 40rpx;

				.left-item {
					display: flex;
					flex-direction: column;

					.time {
						color: #999;
						font-size: 28rpx;
						margin-top: 20rpx;
					}

					.title {
						font-size: 32rpx;
						color: #383838;
						font-weight: bold;
					}
				}

				.score {
					font-size: 34rpx;
					margin-right: 30rpx;
					color: #3FAB4E;
					font-weight: bold;
				}

				.score1 {
					font-size: 34rpx;
					margin-right: 30rpx;
					color: #F80406;
					font-weight: bold;
				}
			}
		}
	}
</style>